<extend file="resource/view/site"/>
<block name="content">
    <ul class="nav nav-tabs">
        <li class="active"><a href="#">会员列表</a></li>
        <li><a href="{{site_url('site/MemberPost')}}">添加会员</a></li>
    </ul>
    <form action="" method="post" class="form-horizontal" onsubmit="return false;">
        <div class="panel panel-default">
            <div class="panel-body">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th width="50">删除</th>
                        <th width="100">会员编号</th>
                        <th>昵称/真实姓名</th>
                        <th>会员组</th>
                        <th>手机</th>
                        <th>邮箱</th>
                        <th>余额/积分</th>
                        <th>注册时间</th>
                        <th class="text-right">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <foreach from="$data" value="$d">
                        <tr>
                            <td>
                                <input type="checkbox" name="uid[]" value="{{$d['uid']}}">
                            </td>
                            <td>{{$d['uid']}}</td>
                            <td>{{$d['nickname']}}<br/>{{$d['realname']}}</td>
                            <td>{{$d['title']}}</td>
                            <td>{{$d['mobile']}}</td>
                            <td>{{$d['email']}}</td>
                            <td>
                                <span class="label label-info" style="line-height: 1.8">积分:{{$d['credit1']}}</span>
                                <br/>
                                <span class="label label-warning">余额:{{$d['credit2']}}</span>
                            </td>
                            <td>
                                {{date('Y-m-d',$d['createtime'])}}
                            </td>
                            <td>
                                <div class="btn-group pull-right" role="group" aria-label="...">
                                    <a href="javascript:;" data-type="credit1" data-uid="{{$d['uid']}}" onclick="util.tradeCredit(this)" class="btn btn-default">积分</a>
                                    <a href="javascript:;" data-type="credit2" data-uid="{{$d['uid']}}" onclick="util.tradeCredit(this)" class="btn btn-default">余额</a>
                                    <a href="{{site_url('site/MemberEdit')}}&uid={{$d['uid']}}" class="btn btn-default">编辑</a>
                                </div>
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
        </div>
        <ul class="pagination">
            {{$data->links()}}
        </ul>
        <button class="btn btn-primary col-lg-1" onclick="del()">删除</button>
    </form>
</block>
<script>
    function del() {
        require(['util'], function (util) {
            if ($("[name*='uid']:checked").length == 0) {
                util.message('你还没有选择要删除的用户', '', 'warning');
                return;
            }
            util.confirm('确定删除用户吗?', function () {
                $.post("{{site_url('delete')}}", $("form").serialize(), function (res) {
                    if (res.valid == 1) {
                        util.message(res.message, 'refresh', 'success');
                    } else {
                        util.message(res.message, '', 'error');
                    }
                }, 'json');
            });
        });
    }

</script>